﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class public_page_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if (!IsPostBack)
            {
                string 控件前导字符 = "ctl00$CPH_Right$";
                int ddl_cost_id = Convert.ToInt32(Request.Form[控件前导字符 + "ddl_cost_id"]);
                int ddl_cost_organization_id = Convert.ToInt32(Request.Form[控件前导字符 + "ddl_cost_organization_id"]);
                int ddl_cost_recharge_id = Convert.ToInt32(Request.Form[控件前导字符 + "ddl_cost_recharge_id"]);
                string txt_date_start = SysCommon.ProcessSqlStr(Request.Form[控件前导字符 + "txt_date_start"]);
                string txt_date_end = SysCommon.ProcessSqlStr(Request.Form[控件前导字符 + "txt_date_end"]);
                int ddl_status = Convert.ToInt32(Request.Form[控件前导字符 + "ddl_status"]);

                System.Text.StringBuilder sbstr = new System.Text.StringBuilder(200);
                sbstr.Append("select t1.*,t2.cost_name,t3.cost_organization_name,case t1.operate_status when 1 then '支付成功' when 2 then '支付失败' when 4 then '已冲正' when 5 then '冲正失败' else '未知' end as operate_status_str,t1.user_money+t1.handlingfee_money as user_money2 from t_user_paid t1,t_cost t2,t_cost_organization t3 where t1.cost_id=t2.cost_id and t1.cost_organization_id=t3.cost_organization_id and t1.user_id=");
                sbstr.Append(SysCommon.getUser_id());
                sbstr.Append(" and ");
                if (ddl_cost_id > 0)
                {
                    sbstr.Append("t1.cost_id=");
                    sbstr.Append(ddl_cost_id);
                    sbstr.Append(" and ");
                }
                if (ddl_cost_organization_id > 0)
                {
                    sbstr.Append("t1.cost_organization_id=");
                    sbstr.Append(ddl_cost_organization_id);
                    sbstr.Append(" and ");
                }
                if (txt_date_start.Length > 0 && SysCommon.IsDate(txt_date_start) == true)
                {
                    sbstr.Append("t1.addtime>='");
                    sbstr.Append(txt_date_start);
                    sbstr.Append("' and ");
                }
                if (txt_date_end.Length > 0 && SysCommon.IsDate(txt_date_end) == true)
                {
                    sbstr.Append("CONVERT(datetime, CONVERT(varchar, t1.addtime, 103), 103)<='");
                    sbstr.Append(txt_date_end);
                    sbstr.Append("' and ");
                }

                sbstr.Append("1=1 order by t1.addtime");

                System.Data.DataTable dt = DataBaseOperate_SQLServer.GetDataTable(sbstr.ToString());

                DataView dv = dt.DefaultView;
                if ((dv.Count == 0))
                {
                    DataRowView d = dv.AddNew();
                    DGV_result.DataSource = dv;
                    DGV_result.DataBind();
                    Int32 columnCount = DGV_result.Rows[0].Cells.Count;
                    DGV_result.Rows[0].Cells.Clear();
                    DGV_result.Rows[0].Cells.Add(new TableCell());
                    DGV_result.Rows[0].Cells[0].ColumnSpan = columnCount;
                    DGV_result.Rows[0].Cells[0].Text = "No Records Found.";
                    DGV_result.Rows[0].Visible = false;
                }
                else
                {
                    DGV_result.DataSource = dv;
                    int PageMax = (int)Math.Ceiling((double)(dv.Count / DGV_result.PageSize)) - 1;
                    if ((DGV_result.PageIndex > PageMax))
                    {
                        DGV_result.PageIndex = 0;
                    }
                    DGV_result.DataBind();
                }

                DGV_result.DataSource = dt;
                DGV_result.DataBind();


            }

        }
        catch
        {
        }
    }
}
